const mongoose = require('mongoose');
const moment = require('moment');
const roleSchema = mongoose.Schema({
    roleName: String,
    roleCode: String,
    permissionCharacters: String,
    purview:String,
    deptmentIds:Array,
    order: Number,
    menuIds: Array,
    state: String,
    remark: String,
}, {
    collection: 'role', timestamps: true,
    toJSON: {
        virtuals: true,
        transform: (doc, ret) => {
            ret.createdAt = moment(ret.createdAt).format('YYYY-MM-DD HH:mm:ss');
            ret.updatedAt = moment(ret.updatedAt).format('YYYY-MM-DD HH:mm:ss');
            delete ret.__v;
            id = ret._id;
            return ret;
        }
    },
    toObject: { virtuals: true }
});
const Role = module.exports = mongoose.model('role', roleSchema);